package com.rsk.api;

import com.alibaba.dubbo.config.annotation.Reference;
import com.rsk.api.common.ReturnUtils;
import com.rsk.service.SysCompanyContractsService;
import com.rsk.service.SysCompanyTypesService;
import com.rsk.utils.result.Result;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.ws.rs.QueryParam;
import java.util.Date;

/**
 * 机构合约
 * @author myr
 */

@RestController
@RequestMapping(value="/sys/comcontracts")
public class SysCompanyContractsApi {

    @Reference(interfaceClass = SysCompanyTypesService.class, protocol = "dubbo")
    private SysCompanyContractsService sysCompanyContractsService;


    /**
     * 删除机构合约
     * @param id
     * @param Authorization
     * @return
     */
    //@RequiresPermissions("sys_users:save")
    @PostMapping(value="/delSysCompanyContracts" )
    public Result<String> delSysCompanyContracts(@QueryParam("id") Long id,
                                                @RequestHeader("Authorization") String Authorization){
        //String operatorUser = JwtUtil.getClaim(Authorization, "account");
        Long operatorUser = 123L;
        int i = sysCompanyContractsService.delSysCompanyContracts(id, operatorUser);
        return ReturnUtils.returnDataByOne(i);
    }

    /**
     * 新增机构合约
     * @param id
     * @param contractCompany  签约机构
     * @param contractNmber    合约编号
     * @param contractAddress  合约附件地址
     * @param contractStartTime  合约开始时间
     * @param contractEndTime    合约结束时间
     * @param Authorization
     * @return
     */

    //@RequiresPermissions("sys_users:save")
    @PostMapping(value="/saveSysCompanyContracts")
    public Result<String> saveSysCompanyContracts(@QueryParam("id") Long id,
                                              @QueryParam("contractCompany") String contractCompany,
                                              @QueryParam("contractNmber") String contractNmber,
                                              @QueryParam("contractAddress") String contractAddress,
                                              @QueryParam("contractStartTime") Date contractStartTime,
                                              @QueryParam("contractEndTime")  String contractEndTime,
                                              @RequestHeader("Authorization") String Authorization){
        //String operatorUser = JwtUtil.getClaim(Authorization, "account");
        Long operatorUser = 123L;
        int i = sysCompanyContractsService.saveSysCompanyContracts(id,contractCompany,contractNmber,contractAddress,contractStartTime,contractEndTime,operatorUser);
        return ReturnUtils.returnDataByOne(i);
    }


}
